<?php 
 
require_once('admin_inc_path.php');


   

 if (isset($_POST['save'])):
         
    $response = DAOFactory::getCommonFooterDAO()->queryAll();
    
     if(empty($response)):
        $cf = new CommonFooter();
     else:
         $cf = $response[0];
     endif;
       
       $cf->text1En = $_POST['text1_en'];
       $cf->text1Sv = $_POST['text1_sv'];
       $cf->text2En = $_POST['text2_en'];
       $cf->text2Sv = $_POST['text2_sv'];
       $cf->text3En = $_POST['text3_en'];
       $cf->text3Sv = $_POST['text3_sv'];
       $cf->text4En = $_POST['text4_en'];
       $cf->text4Sv = $_POST['text4_sv'];
       
       if(empty($response)):
        $response=DAOFactory::getCommonFooterDAO()->insert($cf);
            if($response):
                echo __INSERTED__;
            endif;
            //echo 'Value inserted:-- '.var_dump($response);
       else:
           $response=DAOFactory::getCommonFooterDAO()->update($cf);
           //echo 'Value updated:-- '.var_dump($response);
           if($response):
               echo __UPDATED__;
           endif;
       endif;
 else:
     $response = DAOFactory::getCommonFooterDAO()->queryAll();
     $cf = $response[0];
 endif;
       
 
include_once('inc/admin_header.php');
?>		



<div class="admin_content_wrapper">
			<h1>Footer</h1>
			<h2>Left Column</h2>
			
                        <form action="" method="POST">
				<div class="admin_segment">
						<table>
							<tr>
								<td>

								</td>
								<td>
									<h3>Svenska</h3>
								</td>
								<td>
									<h3>Engelska</h3>
								</td>
							</tr>
							<tr>
								<td>
									<h3>Text:</h3>
								</td>
								<td>
                                                                    <input type="text" name="text1_sv" value="<?php echo $cf->text1Sv; ?>"/>
								</td>
								<td>
                                                                    <input type="text" name="text1_en" value="<?php echo $cf->text1En; ?>"/>
								</td>
							</tr>
							<tr>
								<td>
									<h3>Link Name:</h3>
								</td>
								<td>
									<input type="text" name="text2_sv" value="<?php echo $cf->text2Sv; ?>"/>
								</td>
								<td>
									<input type="text" name="text2_en" value="<?php echo $cf->text2En; ?>"/>
								</td>
							</tr>
							<tr>
								<td>
									<h3>Ext Link URL:</h3>
								</td>
								<td>
									<input type="text" name="text3_sv" value="<?php echo $cf->text3Sv; ?>"/>
								</td>
								<td>
									<input type="text" name="text3_en" value="<?php echo $cf->text3En; ?>"/>
								</td>
							</tr>
							<tr>
								<td>
									<h3>Ext Link Name:</h3>
								</td>
								<td>
									<input type="text" name="text4_sv" value="<?php echo $cf->text4Sv; ?>"/>
								</td>
								<td>
									<input type="text" name="text4_en" value="<?php echo $cf->text4En; ?>"/>
								</td>
							</tr>
						</table>
                                    <input type="submit" value="Save and Upload" name="save"/>
				</div>
			</form>

		</div>
<?php include_once('inc/admin_footer.php') ?>